package com.happy.sky.design.singleton;

/**
 * @name: Singleton <tb>
 * @title: 单列设计模式-静态内部类  <tb>
 * @author: cuixinfu@51play.com <tb>
 * @date: 2021/4/25 10:53 <tb>
 */
public class Singleton4 {

    public static void main(String[] args) {
        System.out.println(InnerClassSinglon.getInstance());
        System.out.println(InnerClassSinglon.getInstance());
        System.out.println(InnerClassSinglon.getInstance());
    }

}

class InnerClassSinglon{
    private static class InnerClassHolder{
        private static InnerClassSinglon instance = new InnerClassSinglon();
    }

    private InnerClassSinglon(){

    }

    public static InnerClassSinglon getInstance(){
        return InnerClassHolder.instance ;
    }
}
